// run: time $exec < input
#include <iostream>
#include <queue>
#include <string>

int const maxn = 1002;
char da[maxn][maxn];
int input_pos[maxn];
int n, m, k;
std::string s;

struct pos
{
	pos(int x, int y) : x(x), y(y) {}
	int x, y;
};

// 0: up   1: ..   2: right   3: ..   4: down   5: ..   6: left   7: ..
pos opt[] = {
				pos(-1, 0), pos(-1, 1), pos(0, 1), pos(1, 1),
				pos(1, 0), pos(1, -1), pos(0, -1), pos(-1, -1),
			};

bool inrange(pos p)
{
	return (0 <= p.x && p.x < n) && (0 <= p.y && p.y < m);
}

pos pos_next(pos p, pos const & delta)
{
	p.x += delta.x;
	p.y += delta.y;
	return p;
}

pos on_edge_next(pos p, int & dir)
{
	if (!inrange(pos_next(p, opt[dir])))
		dir = (dir + 2) % 8;
	p.x += opt[dir].x;
	p.y += opt[dir].y;
	return p;
}

struct first_ch_pos
{
	int x, y, len;
	char dir;
};

namespace tue
{
	namespace detail
	{
		int const alphabet_size = 26;
		int const max_size = 400000;

		int next[max_size][alphabet_size];
		first_ch_pos out[max_size];
		int fail[max_size];
		int word_tail_count[max_size];

		struct trie
		{
			trie() { reset(); }

			void reset()
			{
				current_free = 0;
				root = allocate();
			}

			void insert(std::string const & s, int p)
			{
				int now = root;
				int len = s.size();
				for (int i = 0; i < len; now = next[now][s[i++] - 'A'])
					if (next[now][s[i] - 'A'] == -1)
						next[now][s[i] - 'A'] = allocate();
				word_tail_count[now]++;
				out[now].len = len;
				input_pos[p] = now;
			}

			void make_ac_automaton()
			{
				std::queue<int> q;
				fail[root] = root;
				for (int ch = 0; ch < alphabet_size; ch++)
					if (next[root][ch] == -1)
						next[root][ch] = root;
					else {
						fail[next[root][ch]] = root;
						q.push(next[root][ch]);
					}

				while (!q.empty()) {
					int now = q.front(); q.pop();
					for (int ch = 0; ch < alphabet_size; ch++)
						if (next[now][ch] == -1)
							next[now][ch] = next[fail[now]][ch];
						else {
							fail[next[now][ch]] = next[fail[now]][ch];
							q.push(next[now][ch]);
						}
				}
			}

			void match(pos p, pos delta, int dir)
			{
				int now = root;
				for (; inrange(p); p = pos_next(p, delta)) {
					int ch = da[p.x][p.y] - 'A';
					now = next[now][ch];
					for (int tmp = now; tmp != root; tmp = fail[tmp]) {
						if (word_tail_count[tmp]) {
							out[tmp].x = p.x - opt[dir].x * (out[tmp].len - 1);
							out[tmp].y = p.y - opt[dir].y * (out[tmp].len - 1);
							out[tmp].dir = dir + 'A';
						}
					}
				}
			}

		private:

			int allocate()
			{
				for (int i = 0; i < alphabet_size; i++)
					next[current_free][i] = -1;
				word_tail_count[current_free] = 0;
				return current_free++;
			}

			int current_free;
			int root;
		};
	}

	using detail::trie;
}

int main()
{
	std::ios::sync_with_stdio(false);
	tue::trie aca;
	std::cin >> n >> m >> k;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < m; j++) std::cin >> da[i][j];

	for (int i = 0; i < k; i++) {
		std::cin >> s;
		aca.insert(s, i);
	}
	aca.make_ac_automaton();

	for (int dir = 0; dir < 8; dir++) {
		int d = 2;
		pos p(0, 0);
		do {
			aca.match(p, opt[dir], dir);
			p = on_edge_next(p, d);
		} while (inrange(p) && (p.x || p.y));
	}

	for (int i = 0; i < k; i++)
		std::cout << tue::detail::out[input_pos[i]].x << ' ' <<
				tue::detail::out[input_pos[i]].y << ' ' <<
					tue::detail::out[input_pos[i]].dir << '\n';
}

